package com.service.impl;

import com.dao.impl.UserDaoImpl;
import com.javabean.User;
import com.service.UserService;

public class UserServiceImpl implements UserService {

    @Override
    public void registerUser(User user) {
        new UserDaoImpl().addUser(user);
    }

    //用户登录时判断账号密码是否正确
    @Override
    public User login(String username, String password) {

        return new UserDaoImpl().queryUserByUsernameAndPassword(username, password);
    }

    //判断是否存在用户名
    @Override
    public boolean existUsername(String username) {
        if (new UserDaoImpl().queryUserByUsername(username) == null) {
            return false;//用户不存在
        } else
            return true;//用户存在
    }
}
